package com.dc.ssjt.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dc.ssjt.config.db.DataSource;
import com.dc.ssjt.config.db.DataSourceNames;
import com.dc.ssjt.entity.Storage;
import com.dc.ssjt.mapper.StorageMapper;
import com.dc.ssjt.service.StorageService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * 库存服务，业务逻辑
 *
 * @author duchao
 */
@Slf4j
@Service
public class StorageServiceImpl extends ServiceImpl<StorageMapper, Storage> implements StorageService {

    /**
     * 扣减库存
     *
     * @param productId 商品id
     * @param count     扣减库存数
     */
    @DataSource(name = DataSourceNames.DS_STORAGE)
    @Override
    public void decrease(Long productId, Integer count) {
        baseMapper.decrease(productId, count);
    }
}
